<?php

class BbcodeHelper extends AppHelper
{
    function process($data)
    {
	$data = str_replace("\n", '<br />', $data);
	$data = preg_replace('/\[link=(.*)\](.*)\[\/link\]/Ui', '<a href="\1">\2</a>', $data);
	$data = preg_replace('/\[url=(.*)\](.*)\[\/url\]/Ui', '<a href="\1">\2</a>', $data);
	$data = ereg_replace('(^|[^"])((https?|ftp|irc)://[^<>[:space:]]+[[:alnum:]/;])', '\1<a href="\2">\2</a>', $data);
	$data = preg_replace('/\[abbr=(.*)\](.*)\[\/abbr\]/Ui', '<acronym title="\1">\2</acronym>', $data);
	$data = preg_replace('/\[q=(.*)\]/Ui', '<a href="' . $this->webroot . 'quotes/view/\1">quote #\1</a>', $data);
	$data = preg_replace('/\[h\](.*)\[\/h\]/Ui', '<h2>\1</h2>', $data);
	$data = preg_replace('/\[s\](.*)\[\/s\]/Ui', '<del>\1</del>', $data);
	$data = preg_replace('/\[b\](.*)\[\/b\]/Ui', '<strong>\1</strong>', $data);
	$data = preg_replace('/\[i\](.*)\[\/i\]/Ui', '<em>\1</em>', $data);
	$data = preg_replace('/\[u\](.*)\[\/u\]/Ui', '<span class="quote-u">\1</span>', $data);
									
	return $data;
    }
}

?>